POV-Ray : Newsgroups : povray.general : Q: missing cylinder : Re: Q: missing cylinder Server Time
12 Aug 2024 09:22:03 EDT (-0400)
  Re: Q: missing cylinder  
From: Nathan Kopp
Date: 28 Feb 1999 00:55:36
Message: <36D8DA49.A828175E@Kopp.com>
You're running into a round-off problem in the line "#while (i2 <= 1)".
Usually it's best to use integer values 'for' loop (or in a while loop
trying to act as a foor loop).  Changing your loop to the following fixes
the problem:
#declare iStep=1/Steps;
#declare i=0;
#declare n=0;  // using n as the counter
#declare i2=i+iStep;
#while(n<Steps)  // checking an integer, not a floating point
  #declare P1= StartPoint+(Length*i);
  #declare P2= StartPoint+(Length*i2);
  cylinder {P1, P2, 0.05 pigment {rgb 1}}
  #declare i= i2;
  #declare i2= i+iStep;
  #declare n=n+1;  // increment the loop counter
#end

-Nathan

ingo wrote:
> 
> What goes wrong here?
> In the following scene, if you change Steps to 9, 11, 21, 25 ...... there is
> one cylinder missing. What thinking error did I make?
> 
> ingo.
> 
> #version 3.1;
> #global_settings {assumed_gamma 1.0}
> light_source {<500,500,-500> rgb 1}
> camera {location 2*y look_at 0}
> 
> #declare StartPoint= <-1,0,0>;
> #declare Length= <2,0,0>;
> 
> #declare Steps=10;
> 
> #declare iStep=1/Steps;
> #declare i=0;
> #declare i2=i+iStep;
> #while (i2 <= 1)
>   #declare P1= StartPoint+(Length*i);
>   #declare P2= StartPoint+(Length*i2);
>   cylinder {P1, P2, 0.05 pigment {rgb 1}}
>   #declare i= i2;
>   #declare i2= i+iStep;
> #end
> 
> sphere { <-1,0,0>,0.05 pigment{rgb 10}}
> sphere { < 1,0,0>,0.05 pigment{rgb 10}}
> 
> --
> Met dank aan de muze met het glazen oog.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.